package com.example.demo.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.SysFile;
import com.example.demo.entity.SysQuestionAnswer;
import com.example.demo.mapper.SysFileMapper;
import com.example.demo.service.SysFileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统文件表 服务实现类
 * </p>
 *
 * @author ld&zjw
 * @since 2024-04-03
 */
@Service
public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> implements SysFileService {
    @Autowired
    SysFileMapper sysFileMapper;

    @Override
    public Page<SysFile> findPage(Integer pageNum, Integer pageSize, String fileName,String bucketName) {
        LambdaQueryWrapper<SysFile> wrapper = Wrappers.<SysFile>lambdaQuery();
        if (StrUtil.isNotBlank(fileName)) {
            wrapper.like(SysFile::getFileName, fileName);
        }
        if (StrUtil.isNotBlank(bucketName)){
            wrapper.like(SysFile::getBucketName,bucketName);
        }
        Page<SysFile> newsPage = sysFileMapper.selectPage(new Page<>(pageNum, pageSize), wrapper);
        return newsPage;
    }
}
